package com.ruoyi.web.controller.system.Fdongbei;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.Fdongbei.domain.TbRfid;
import com.ruoyi.system.Fdongbei.service.ITbRfidService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * RFIDController
 * 
 * @author ruoyi
 * @date 2025-01-07
 */
@RestController
@RequestMapping("/system/rfid")
public class TbRfidController extends BaseController
{
    @Autowired
    private ITbRfidService tbRfidService;

    /**
     * 查询RFID列表
     */
    @PreAuthorize("@ss.hasPermi('system:rfid:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbRfid tbRfid)
    {
        startPage();
        List<TbRfid> list = tbRfidService.selectTbRfidList(tbRfid);
        return getDataTable(list);
    }

    /**
     * 导出RFID列表
     */
    @PreAuthorize("@ss.hasPermi('system:rfid:list')")
    @Log(title = "RFID", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbRfid tbRfid)
    {
        List<TbRfid> list = tbRfidService.selectTbRfidList(tbRfid);
        ExcelUtil<TbRfid> util = new ExcelUtil<TbRfid>(TbRfid.class);
        util.exportExcel(response, list, "RFID数据");
    }

    /**
     * 获取RFID详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:rfid:list')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbRfidService.selectTbRfidById(id));
    }

    /**
     * 新增RFID
     */
    @PreAuthorize("@ss.hasPermi('system:rfid:list')")
    @Log(title = "RFID", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbRfid tbRfid)
    {
        return toAjax(tbRfidService.insertTbRfid(tbRfid));
    }

    /**
     * 修改RFID
     */
    @PreAuthorize("@ss.hasPermi('system:rfid:list')")
    @Log(title = "RFID", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbRfid tbRfid)
    {
        return toAjax(tbRfidService.updateTbRfid(tbRfid));
    }

    /**
     * 删除RFID
     */
    @PreAuthorize("@ss.hasPermi('system:rfid:list')")
    @Log(title = "RFID", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbRfidService.deleteTbRfidByIds(ids));
    }
}
